#include <iostream>
#include <unistd.h>
#include <threads.h>

using namespace std;

void* run(void* arg){
    while(true){
        cout<<"我是子线程："<<(char*)arg<<endl;
        sleep(1);
    }
}

const int num = 5;
int main(){
    pthread_t pth[num];
    for(int i = 1;i<=num;++i){
        char* name = new char[64];
        snprintf(name,sizeof name,"thread%d",i);
        pthread_create(&pth[i-1],nullptr,run,name);
    }
    while(true){
        cout<<"我是主线程: main"<<endl;
        sleep(2);
    }
    
    return 0;
}